﻿using System;
using System.Collections.Generic;
using Hematology.Tools;

namespace Hematology.UserSite.controls
{
	public partial class AdminPanelItem : System.Web.UI.UserControl
	{
		public string ItemTitle { get; set; }
		public string ItemLink { get; set; }
		public string IconClass { get; set; }
		public Dictionary<string, string> HyperLinkList { get; set; }

		public EnumHelper.AdminProfileItemKey TargetProfileItem { get; set; }

		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				pnlIcon.CssClass = string.Format("adminPanelContainerItemIcon {0}", IconClass);

				btnCommon.Text = ItemTitle;
				btnCommon.PostBackUrl = ItemLink;

				//rptLinks.DataSource = HyperLinkList;
				//rptLinks.DataBind();

				Dictionary<string, string> dLinkList = new Dictionary<string, string>();

				switch (TargetProfileItem)
				{
					case EnumHelper.AdminProfileItemKey.Community:
						dLinkList.Add("История", "/admin/Community.aspx?topic=history");
						dLinkList.Add("Управление", "/admin/Community.aspx?topic=management");
						dLinkList.Add("Устав", "/admin/Community.aspx?topic=statute");
						dLinkList.Add("Конфликт интересов", "/admin/Community.aspx?topic=collision");
						break;
					case EnumHelper.AdminProfileItemKey.News:
						dLinkList.Add("Список", "/admin/News.aspx?view=list");
						dLinkList.Add("Добавить", "/admin/News.aspx?view=add");
						break;
					default:
						dLinkList.Add("Список", "/admin/Community.aspx?topic=history");
						dLinkList.Add("Добавить", "/admin/Community.aspx?topic=management");
						break;
				}

				rptLinks.DataSource = dLinkList;
				rptLinks.DataBind();
			}
		}
	}
}